// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.1.14
description: >
  Return false if target is not extensible, without changing the prototype.
info: |
  26.1.14 Reflect.setPrototypeOf ( target, proto )

  ...
  3. Return target.[[SetPrototypeOf]](proto).

  9.1.2 [[SetPrototypeOf]] (V)

  ...
  5. If extensible is false, return false.
  ...
features: [Reflect, Reflect.setPrototypeOf]
---*/

function Test() {
    var o1 = {};
    Object.preventExtensions(o1);
    assert.sameValue(Reflect.setPrototypeOf(o1, {}), false);
    assert.sameValue(Object.getPrototypeOf(o1), Object.prototype);

    var o2 = {};
    Object.preventExtensions(o2);
    assert.sameValue(Reflect.setPrototypeOf(o2, null), false);
    assert.sameValue(Object.getPrototypeOf(o2), Object.prototype);

    var o3 = Object.create(null);
    Object.preventExtensions(o3);
    assert.sameValue(Reflect.setPrototypeOf(o3, {}), false);
    assert.sameValue(Object.getPrototypeOf(o3), null);
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
